import request from "@/utils/request";

// cn下的组列表 分页
export const pageList = query => {
  return request({
    url: "/ad/group/pageList",
    method: "get",
    params: query
  });
};

//组信息
export const info = sAMAcountName => {
  return request({
    url: `/ad/group/${sAMAcountName}/info`,
    method: "get"
  });
};

//组成员列表
export const members = query => {
  return request({
    url: `/ad/group/members`,
    method: "get",
    params: query
  });
};
//查询
export const searchMembers = query => {
  return request({
    url: `/ad/group/searchMembers`,
    method: "get",
    params: query
  });
};
//组成员列表
export const membersPage = (distinguishedName, query) => {
  return request({
    url: `/ad/group/${distinguishedName}/membersPage`,
    method: "get",
    params: query
  });
};
//添加组
export const addGroup = (orgDN, data) => {
  return request({
    url: `/ad/group/add`,
    method: "post",
    data,
    params: { orgDN }
  });
};

//删除组
export const deleteGroup = samAccountName => {
  return request({
    url: `/ad/group/${samAccountName}`,
    method: "delete"
  });
};
// 导入
export const importExcel = query => {
  return request.post(
    "/ad/group/importGroupTemplate",
    query

 );
};
// 导出
export const exportGroupExcel = query => {
  return request({
    url: "/ad/group/exportExcel",
    method: "post",
    params: query,
    responseType: "blob"
  });
};

// 从剪切板
export const importMemberFromClipboard = data => {
  return request({
    url: "/ad/group/importMemberFromClipboard",
    method: "post",
    params: data,
  });
};

//添加组成员
export const addGroupMember = (dn, data) => {
  return request({
    url: `/ad/group/${dn}/addGroupMember`,
    method: "post",
    data
  });
};

//移除组成员
export const removeGroupMember = (dn, data) => {
  return request({
    url: `/ad/group/${dn}/removeGroupMember`,
    method: "delete",
    data
  });
};

export default {
  pageList,
  info,
  members,
  searchMembers,
  membersPage,
  addGroup,
  deleteGroup,
  exportGroupExcel,
  importMemberFromClipboard,
  removeGroupMember,
  addGroupMember,
  importExcel
};
